#################################################################
# This docker image build file creates an image that contains
# zookeeper and kafka server.
#
#                    ##        .
#              ## ## ##       ==
#           ## ## ## ##      ===
#       /""""""""""""""""\___/ ===
#  ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
#       \______ o          __/
#         \    \        __/
#          \____\______/
#
# Component:    RNTD
# Author:       Dou Chunrong <douchunrong@gmail.com>
# Copyright:    (c) 2015-2016 RNTD Ltd. All rights reserved.
#################################################################
#Version 0.0.1
FROM ubuntu:14.04
MAINTAINER douchunrong <douchunrong@gmail.com>

#设置 kafka 环境变量
ENV KAFKA_VER 0.8.2.1
ENV KAFKA_API_VER 2.11
ENV KAFKA_HOME /kafka


#确认下载 wget
RUN apt-get update
RUN apt-get -y --force-yes  upgrade
RUN apt-get -y --force-yes install wget

#安装 jdk
RUN apt-get install -y  openjdk-7-jdk
RUN apt-get install -y  openjdk-7-jre

#下载 kafka
RUN wget http://mirrors.cnnic.cn/apache/kafka/${KAFKA_VER}/kafka_${KAFKA_API_VER}-${KAFKA_VER}.tgz
RUN tar -zxvf kafka_${KAFKA_API_VER}-${KAFKA_VER}.tgz
RUN mv kafka_${KAFKA_API_VER}-${KAFKA_VER} kafka/


ADD scripts/zookeeper.properties ${KAFKA_HOME}/config/
ADD scripts/server.properties ${KAFKA_HOME}/config/

ADD scripts/start-kafka.sh /usr/bin/start-kafka.sh

RUN cat ${KAFKA_HOME}/config/server.properties

RUN chmod 777 /usr/bin/start-kafka.sh
#端口
EXPOSE 2181 9092

CMD ["/usr/bin/start-kafka.sh"]
